package com.hym.travel.service.serviceImpl;

import com.hym.travel.dao.ProvinceDao;
import com.hym.travel.entity.Province;
import com.hym.travel.service.ProvinceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProvinceServiceImpl implements ProvinceService {

    @Autowired
    private ProvinceDao provinceDao;

    @Override
    public void save(Province province) {
        if(provinceDao.findOne(province.getName()) != null){
            throw new RuntimeException("该省份已存在，请重新输入");
        }
        provinceDao.save(province);
    }

    @Override
    public Province findOne(String id) {
        return provinceDao.findOne(id);
    }

    @Override
    public List<Province> findAll() {
        return null;
    }

    @Override
    public List<Province> findByPage(Integer start, Integer rows) {
        return provinceDao.findByPage(start,rows);
    }

    @Override
    public Integer findTotals() {
        return provinceDao.findTotals();
    }

    @Override
    public void delete(String id) {
         provinceDao.delete(id);
    }

    @Override
    public void update(Province province) {
        provinceDao.update(province);
    }

}
